package lion.json.handlers;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;

import lion.json.IJsonHandler;

public class InputStreamHandler implements IJsonHandler {

	private IJsonHandler handler = new ByteArrayHandler();

	@Override
	public void handle(Object o, Writer out) throws IOException {

		DataInputStream ins = new DataInputStream((InputStream) o);
		byte[] bytes = new byte[ins.available()];
		ins.readFully(bytes);
		handler.handle(bytes, out);
	}
}
